package com.test.hibernate.hql.entity;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.util.Objects;

/**
 * @author lzy
 * @version v1.0
 * Create DateTime: 2018/9/20 8:43
 */
@Setter
@Getter
@NoArgsConstructor
public class Employee {
    private Integer id;
    private String name;
    private float salary;
    private String email;
    private Department dept;

    public Employee(String email, float salary, Department dept) {
        this.salary = salary;
        this.email = email;
        this.dept = dept;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Employee employee = (Employee) o;
        return Float.compare(employee.salary, salary) == 0 &&
                Objects.equals(id, employee.id) &&
                Objects.equals(name, employee.name) &&
                Objects.equals(email, employee.email);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, name, salary, email);
    }

    @Override
    public String toString() {
        return "Employee{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", salary=" + salary +
                ", email='" + email + '\'' +
                '}';
    }
}
